#include <bits/stdc++.h>
// 2025/04/05
// tag:
// Author: Forever
using namespace std;
using int64 = int64_t;
#define int long long

int n, m, ans, cnt, c, h[100001];
bool vis[100001];

class UF {
public:
    int parents[100001], cnt;

    UF(int n)
    {
        cnt = n;
        for (int i = 1; i <= n; i++)
            parents[i] = i;
    };

    int find(int i)
    {
        if (parents[i] != i)
            return parents[i] = find(parents[i]);
        return parents[i];
    }

    void un(int i, int j)
    {
        int ri = find(i), rj = find(j);
        if (ri == rj)
            return;
        parents[ri] = rj;
        cnt--;
    }

    int count()
    {
        return cnt;
    }

    bool connected(int p, int q)
    {
        return find(p) == find(q);
    }
};

class edge {
public:
    int u, v, w;
    edge(int u, int v, int w)
        : u(u)
        , v(v)
        , w(w) { };
    edge()
        : u(0)
        , v(0)
        , w(0) { };
    bool operator<(const edge& e) const
    {
        if (h[v] != h[e.v])
            return h[v] > h[e.v];
        return w < e.w;
    }
};

edge edges[1000001];
vector<edge> g[100001];

void bfs(){
    queue<int> q;
    q.push(1);
    vis[1] = true;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto e : g[u]) {
            edges[++c] = e;
            if (vis[e.v])
                continue;
            vis[e.v] = true;
            cnt++;
            q.push(e.v);
        }
    }
}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    for (int i = 1; i <= m; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        if (h[u] >= h[v])
            g[u].push_back({ u, v, w });
        if (h[u] <= h[v])
            g[v].push_back({ v, u, w });
    }
    bfs();
    sort(edges + 1, edges + c + 1);
    UF uf(n);
    for (int i = 1; i <= c; i++) {
        if (uf.connected(edges[i].u, edges[i].v))
            continue;
        uf.un(edges[i].u, edges[i].v);
        ans += edges[i].w;
    }
    cout << cnt + 1 << " " << ans << endl;
    return 0;
}